package com.kmproject.haifu.mvp.ui.adapter;

import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;

import java.util.List;

public class PopuWindowSelectPxAdapter extends BaseQuickAdapter<String,BaseViewHolder> {
    private int selectIndex=0;
    private BtncliickCallBack mbtncliickCallBack;

    public PopuWindowSelectPxAdapter(@Nullable List<String> data, BtncliickCallBack btncliickCallBack) {
        super(R.layout.popuwindows_seelct_px_item, data);
        mbtncliickCallBack=btncliickCallBack;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        helper.<TextView>getView(R.id.popuwindows_seelct_adress_item2_txt).setText(item);
        helper.<TextView>getView(R.id.popuwindows_seelct_adress_item2_txt).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectIndex=helper.getPosition();
                notifyDataSetChanged();
                if (mbtncliickCallBack!=null)
                {
                    mbtncliickCallBack.callBack(selectIndex,item);
                }
            }
        });
        if (selectIndex==helper.getPosition())
        {
            helper.<TextView>getView(R.id.popuwindows_seelct_adress_item2_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
            helper.<TextView>getView(R.id.popuwindows_seelct_adress_item2_txt) .setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            helper.<ImageView>getView(R.id.popuwindows_seelct_adress_item2).setVisibility(View.VISIBLE);

        }else {
            helper.<TextView>getView(R.id.popuwindows_seelct_adress_item2_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_747474));
            helper.<TextView>getView(R.id.popuwindows_seelct_adress_item2_txt) .setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            helper.<ImageView>getView(R.id.popuwindows_seelct_adress_item2).setVisibility(View.INVISIBLE);
        }

    }

    public interface BtncliickCallBack{
        void callBack(int index, Object content);
    }
}
